import type {TableProps} from "./table.types";
import type {MetaView} from "../tool/meta.types.ts";
import type {UISizeTypes, UITextTypes} from "../morghulis.types.ts";
import type {Component} from "vue";
import type {DaoTypes, DataItem} from "../tool/dao.types.ts";
import type {Orders} from "../tool/query.types.ts";

export type SortableCallbackFn = (newIndex: number, oldIndex: number) => void


export type MTableButton = {
    size?: UISizeTypes,
    handler?: (row: any, event?: Event) => void,
    title?: string | Function,
    type?: UITextTypes | Function,
    link?: boolean | Function,
    plain?: boolean | Function,
    text?: boolean | Function,
    round?: boolean | Function,
    circle?: boolean | Function,
    disabled?: boolean | Function,
    dark?: boolean | Function,
    color?: string | Function,
    tag?: string | Function,
}

export type MTableColumn = {
    label: string
    component: Component,
    width?: string | number,
}

export type DTableProps = {
    auth?: boolean,
    db: DaoTypes,
    entity: string,
    code?: string,
    size?: number,
    page?: number,
    includes?: DataItem,
    excludes?: DataItem,
    orders?: Orders,
    buttons?: MTableButton[],
    columns?: MTableColumn[]
}


export type MorghulisTableProps = TableProps & {
    loading?: boolean,
    view: MetaView,
    buttons?: MTableButton[],
    columns?: MTableColumn[],
    sortableCallback?: SortableCallbackFn
}


export const morghulisTablePropsDefaults = {
    border: true,
    fit: true,
    showHeader: true,
    highlightCurrentRow: false,
    headerCellClassName: 'm-table-header-cell',
    showOverflowTooltip: true,

    // currentRowKey: 'id',
    // rowKey: 'id'
}


